<template>
  <div class="login_bg">
    <div class='login_box'>
      <p class="login_box_logo"><img src="../common/images/logo.png" alt=""></p>
      <p class="marginTop20">大华科技原材料库存优化系统</p>
      <div class="login_text_box">
        <ul class="login_ul">
          <li style="position: relative;">
            <input type="password" placeholder="请输入新密码" class='admin' v-model="newPassword">
            <img src="../common/images/count.png" alt="">
          </li>
          <li style="position: relative;">
            <input type="password" class='admin_password' placeholder="确认密码" v-model="certainNewPassword">
            <img src="../common/images/lock.png" alt="">
          </li>
        </ul>
        <div class="tc">
          <input type="button" style="width: 2rem;margin-right:0.25rem;" class="login_btn" @click="goIndex()" value="确认">
          <input type="button" style="width: 2rem;" class="login_btn" @click="clear()" value="重置">
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import common from '../common/js/common';

  export default {
    data() {
      return {
        newPassword: '',
        certainNewPassword: ''
      }
    },
    methods: {
      login:function(e){
				if(e.keyCode==13){
					this.goIndex();
				}
      },
      clear:function(){
        this.newPassword='';
        this.certainNewPassword='';
      },
      goIndex: function () {
        var _self = this;
        if (this.newPassword == this.certainNewPassword) {
          if(this.newPassword==''){
            alert('密码不能为空！')
          }else if(this.newPassword.length<6){
            alert("密码至少6位！")
          }else{
            var yx_data = {
              "new_password": this.certainNewPassword,
            };
            common.getData(0, common.url_constitute.change_password, "post", yx_data, function (d) {
              _self.$router.push({path: '/login'});
            });
          }
        }else {
          alert('两次密码不一致！')
        }
      },
    },
    mounted(){
    		var $this = this;
        $("body").keydown(function(e){
        	if(e.keyCode==13){
						$this.goIndex();
					}
        });
    }
  }
</script>
<style>
  @import "../common/css/base.css";
  @import "../common/css/yx-login.less";
</style>
